import Cookies from 'js-cookie'

const TokenKey = 'loginToken'
const UserKey = 'userToken'

export function getCookie (key) {
  return Cookies.get(key)
}

export function setCookie (key, value) {
  return Cookies.set(key, value)
}

export function getUserName () {
  return Cookies.get('UserName')
}

export function setUserName (value) {
  return Cookies.set('UserName', value)
}

export function getToken () {
  return Cookies.get(TokenKey)
}

export function setToken (token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken () {
  return Cookies.remove(TokenKey)
}

export function getUser () {
  return Cookies.get(UserKey)
}

export function setUser (User) {
  return Cookies.set(UserKey, User)
}

export function removeUser () {
  return Cookies.remove(UserKey)
}

export function getBaseUri () {
  return process.env.NODE_ENV === 'production' ? window.location.origin : process.env.BASE_API
}
